package com.kcht.sylyg08;


import com.kcht.sylyg08.dao.ITransSequencesDao;
import com.kcth.sylyg08.entity.TransSequences;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import java.util.Date;
import java.util.Objects;

@Singleton
@Startup
public class Initialization {

    @Inject
    private ITransSequencesDao transSequencesDao;

    @PostConstruct
    public void init() {

        TransSequences t = transSequencesDao.selectOneByJPQL("select a from TransSequences a where a.name=?", "SYLYG08_SEQ");
        if (Objects.isNull(t)) {
            t = new TransSequences();
            t.setCurrentValue(0);
            t.setCycle(2);
            t.setIncrement(1);
            t.setLasterTime(new Date());
            t.setMaxValue(9999L);
            t.setName("SYLYG08_SEQ");
            transSequencesDao.save(t);
        }

        //List<Map> maps = applyRecordDao.selectMapListBySQL("select * from t_epcms_applyrecord where status =0 and applyDate < '2017-12-12 00:00:00'");
        //maps.forEach(map -> System.out.println(map.get("applyNo")));
        //manager.distributedTaskScheduling(()-> System.out.println("xxxx"),10,"task1");
        //manager.distributedTaskScheduling(()-> System.out.println("yyyyy"),10,"task2");

/*        Stream.of(

                "3274120171206123749",
                "3323520171206160302",
                "3323520171206160933",
                "3358620171206172653",
                "2164420171207092010",
                "3457620171207152833",
                "1920120171208144507",
                "3732820171208153257",
                "3358620171208154922",
                "3351420171208175340",
                "2067720171211092644",
                "3548720171211093753",
                "3419220171211114147",
                "2024220171211114832",
                "2067720171211121855",
                "2167020171211153422",
                "3948620171211171417",
                "4354820171211203334",
                "2761620171211205517",
                "2654820171211225545"
        ).forEach(no->{
                ADPEvent e=new ADPEvent("EXPORT_APPRELY_RECORD_EVENT",no);
                BusinessEvent entity = new BusinessEvent();
                entity.setPayloadObject(e);
                entity.setNotifyCount(10);
                entity.setName(e.getClass().getSimpleName());
                entity.setEventType(EventLevel.Important);
                edao.save(entity);
        });*/


    }


}
